package day07_collections_map.com.itheima.d4_map;

import java.util.Collection;
import java.util.HashMap;
import java.util.Set;

public class MapDemo2 {
    public static void main(String[] args) {
        HashMap<String, Integer> map = new HashMap<>();
        map.put("张三", 100);
        map.put("张三1", 99);
        map.put("张三2", 98);
        map.put("张三3", 97);
        map.put("张三4", 96);
        System.out.println(map);

        map.put(null, null);
        System.out.println("map = " + map);

        System.out.println("map.size() = " + map.size());
//        map.clear();
//        System.out.println("map = " + map);
        System.out.println("map.isEmpty() = " + map.isEmpty());
        System.out.println("map.get(\"张三\") = " + map.get("张三"));
        System.out.println("map.get(\"张三1\") = " + map.get("张三1"));

        System.out.println("map.remove(\"娃娃\") = " + map.remove("娃娃"));
        System.out.println("map = " + map);

        System.out.println("map.containsKey(\"张三\") = " + map.containsKey("张三"));
        System.out.println("map.containsValue(100) = " + map.containsValue(100));
        System.out.println("map.containsValue(99) = " + map.containsValue(99));

        Set<String> keys = map.keySet();
        for (String key : keys) {
            System.out.println(key + ":" + map.get(key));
        }
        System.out.println("--------------------------------");

        Collection<Integer> values = map.values();
        for (Integer value : values) {
            System.out.println(value);
        }
    }
}
